const mysql = require('mysql')

let connection = mysql.createConnection({
    host: 'localhost',
    port: 3306,
    user: 'root1',
    password: '123456',
    database: 'zhaofang'
})

function exec(sql) {
    return new Promise((resolve, reject) => {
        connection.query(sql, (err, data) => {
            if (err) {
                reject(err)
            } else {
                resolve(data)
            }
        })
    })
}

module.exports = {
    exec
}